Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve AliBuild typing and linter strictness #882

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

singiamtel
Copy link
Collaborator

@singiamtel singiamtel commented Nov 12, 2024

I'm currently trying to type the codebase as much as possible, and use a stronger mypy filter.

Not ready to merge yet, just want to get the tests running

@@ -233,7 +218,7 @@ def fetch_symlinks(self, spec):
os.path.join(self.workdir, links_path, linkname))

def upload_symlinks_and_tarball(self, spec):
pass
dieOnError(True, "HTTP backend does not support uploading directly")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change correct? The tests seem to suggest that it should fail silently, instead of crashing like how the CVMFS backend fails

Comment on lines 70 to 72
destFp = None
try:
destFp = open(dest+".tmp", "wb") if dest else None
if dest: destFp = open(dest+".tmp", "wb")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this is an improvement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this one so destFp is always bounded on the finally block, otherwise if open() throws aliBuild would crash trying to access it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the finally actually needed / working? is there a case where open throws and still returns destFp? Maybe we should fix that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should split the opening of the file from the rest of the try catch...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would live this particular change out and continue with the rest of the PR, since to that I have no particular objections.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, leaving it out

aliBuild Show resolved Hide resolved
@singiamtel singiamtel changed the title WIP: Improve AliBuild typing and linter strictness Improve AliBuild typing and linter strictness Dec 13, 2024
@singiamtel singiamtel force-pushed the improve_typing branch 7 times, most recently from b34d42e to cd0d961 Compare December 13, 2024 15:17
@singiamtel
Copy link
Collaborator Author

I don't understant the CI error at all. Apparently they changed the default output of argparse? But somehow our test suite is getting both, and fails no matter which one I try

(alibuild-kutz)
$ python3.13 aliBuild builda
usage: aliBuild [-h] [-d] [-n] {analytics,architecture,build,clean,deps,doctor,init,version} ...
aliBuild: error: argument action: invalid choice: 'builda' (choose from analytics, architecture, build, clean, deps, doctor, init, version)
(alibuild-kutz)
$ alibuild builda
usage: alibuild [-h] [-d] [-n] {analytics,architecture,build,clean,deps,doctor,init,version} ...
alibuild: error: argument action: invalid choice: 'builda' (choose from 'analytics', 'architecture', 'build', 'clean', 'deps', 'doctor', 'init', 'version')

As a workaround I could either make the test laxer, or make our own argparse Formatter class so at least it's consistent (https://docs.python.org/3/library/argparse.html#formatter-class)

It really is impressive how often Python breaks stuff...

@singiamtel
Copy link
Collaborator Author

singiamtel commented Dec 13, 2024

Otherwise this is ready for merge, I want to make more changes but this PR is already very big, so it's probably best to keep it simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants